< previous page page_684 next page >

Page 684
DisplayLogo=0
BatchMode=0
Any arguments passed to the script itself are included after the scripting host options and script filename. You can retrieve them by using the Arguments collection of the Wscript object:
Dim nCount
nCount = WScript.Arguments.Count
WScript.Echo "There are " & nCount & " arguments."

For i = 0 to nCount - 1
 Wscript.Echo WScript.Arguments(i)
Next
Useful Objects and Methods
The usefulness of any object library depends on the types of objects and methods it exposes to the programmer. Since the Windows Scripting Host is intended to replace or supplement batch files, it includes many useful features for accessing the operating system, including the following:
Creating desktop shortcuts
Mapping network drives
Accessing the Registry
Working with automation objects
Working with NT 5.0 user accounts
You can download sample code to perform all the tasks in the preceding list, along with complete documentation for the Windows Scripting Host, from the Microsoft Web Site. Three main objects let you perform these tasks. You have already seen the WScript object in sample code. The WScript object is available directly from VBScript.
Web.gif
ON THE WEB
The Windows Scripting Host, along with documentation and examples, can be downloaded from the Microsoft Scripting Technology Web page at http://www.microsoft.com/scripting.

Two other objects, Shell and Network, must be referenced through WScript by using the CreateObject function. For example, the following script uses the Run method of the Shell object to run a program and wait for it to finish:
Dim WshShell
Set WshShell = WScript.CreateObject("WScript.Shell")
'first parameter is Window Style, second is Wait
WshShell.Run "notepad",1,True
MsgBox "Done!"
As you work with the Windows Scripting Host, you will see that it contains tremendous power to automate Windows-based tasks.

 
< previous page page_684 next page >